//
//  SYNavigationController.m
//  ChatDemo-UI2.0
//
//  Created by Sylar on 16/8/18.
//  Copyright © 2016年 Sylar. All rights reserved.
//

#import "SYNavigationController.h"
//#import "MainViewController.h"
#import "AppDelegate.h"

@interface SYNavigationController ()

@end

@implementation SYNavigationController

- (instancetype)initWithRootViewController:(UIViewController *)rootViewController
{
    self = [super initWithNavigationBarClass:[UINavigationBar class] toolbarClass:nil];
    if (self) {
        self.viewControllers = @[rootViewController];
        
        self.navigationBarHidden = YES;
    }
    return self;
}

- (void)setNavBarTintColor:(UIColor *)navBarTintColor
{
    if (!navBarTintColor) {
        return;
    }
    
    UINavigationBar *navBar = self.navigationBar;
    UIImage *navBg = [Utils imageWithColor:navBarTintColor size:CGSizeMake(SCREENWIDTH, SafeAreaTopHeight)];
    [navBar setBackgroundImage:navBg forBarMetrics:UIBarMetricsDefault];
    
    [navBar setShadowImage:[Utils imageWithColor:[UIColor colorWithHexString:@"#7D7D7D"] size:CGSizeMake(navBar.width, 0.2)]];
    
    /*
    if ([navBarTintColor isEqual:VineBlueColor]) {
        [navBar setShadowImage:[UIImage new]];
    }else {
        [navBar setShadowImage:[HYUtility imageWithColor:DarkGrayColor size:CGSizeMake(navBar.width, 0.2)]];
    }
     */
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)showShadowImage:(BOOL)showOrHide
{
    UINavigationBar *navBar = self.navigationBar;
    
    if (showOrHide == NO) {
        [navBar setShadowImage:[UIImage new]];
    }else {
        [navBar setShadowImage:[Utils imageWithColor:[UIColor blackColor] size:CGSizeMake(navBar.width, 0.2)]];
    }
}



- (UIViewController *)popViewControllerAnimated:(BOOL)animated{
    
    return [super popViewControllerAnimated:YES];
}


@end
